package doorwifi.wd.patientsation.peripheral.mainapp.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;

import doorwifi.wd.patientsation.peripheral.mainapp.Bean.CallLineUpInfo;
import doorwifi.wd.patientsation.peripheral.mainapp.R;

/**
 * Created by xuhuan on 2017/7/11.
 */

public class CallLineUpInfoAdapter extends BaseAdapter {
    private Context mcontext;
    private ArrayList<CallLineUpInfo> mlist;
    private LayoutInflater layoutInflater;


    public CallLineUpInfoAdapter( Context mcontext,ArrayList<CallLineUpInfo> mlist) {
        this.mcontext = mcontext;
        this.mlist = mlist;
        layoutInflater = LayoutInflater.from(this.mcontext);
    }

    @Override
    public int getCount() {
        return mlist.size();
    }

    @Override
    public Object getItem(int position) {
        return mlist.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Holder holder;
        if(convertView == null){
            convertView = View.inflate(mcontext, R.layout.xh_call_sickbed_lineup_info_layout,null);
            holder = new Holder();
            x.view().inject(holder,convertView);//注解绑定
            convertView.setTag(holder);
        }else {
            holder=(Holder) convertView.getTag();
        }

        holder.lineupinfo_date.setText(mlist.get(position).getDate());
        holder.lineupinfo_time.setText(mlist.get(position).getTime());
        holder.lineupinfo_room.setText(mlist.get(position).getIllnessRoom());
        holder.lineupinfo_bed.setText(mlist.get(position).getIllnessBed());

        return convertView;
    }

    private class Holder{
        @ViewInject(R.id.lineupinfo_date)
        private TextView lineupinfo_date;
        @ViewInject(R.id.lineupinfo_time)
        private TextView lineupinfo_time;
        @ViewInject(R.id.lineupinfo_room)
        private TextView lineupinfo_room;
        @ViewInject(R.id.lineupinfo_bed)
        private TextView lineupinfo_bed;

    }

}
